package cn.com.surker.production.service.impl;

import cn.com.surker.enums.system.DataBaseEnum;
import cn.com.surker.production.entity.ProductionIndentDispatch;
import cn.com.surker.production.dao.IndentDispatchDao;
import cn.com.surker.production.service.IndentDispatchService;
import cn.com.surker.system.dao.DataSourceInfoDao;
import cn.com.surker.system.entity.DataSourceInfo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;

/**
 * <p>
 * 生产派单表 服务实现类
 * </p>
 *
 * @author admin
 * @since 2024-09-26
 */
public class IndentDispatchServiceBaseImpl extends ServiceImpl<IndentDispatchDao, ProductionIndentDispatch> implements IndentDispatchService {

	@Resource
	protected IndentDispatchDao indentDispatchDao;
	@Resource
	protected DataSourceInfoDao dsDao;

	/**
	 * 根据时间查询生产方量
	 * @param orgId
	 * @param startTime
	 * @param endTime
	 * @return
	 */
	public Double findProductionStere(Long orgId, Long lineId, String startTime, String endTime) {
		DataSourceInfo ds = dsDao.queryDSByOriginIdV1(orgId, DataBaseEnum.MYSQL.getCode());
		if (ds == null || ds.getType() != 0)
			return 0.0;
		Double proStere = indentDispatchDao.queryCloudTimeProStere(ds.getCode(), lineId, startTime, endTime);
		return proStere;
	}

}